排序子序列
import java.util.Scanner;

 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long[] arr = new long[n];
        for (int i = 0; i  n; i++) {
            arr[i] = in.nextLong();
        }
        int count = 0;
        int i = 0;
        while (i  n) {
            if (i == n - 1) {
                count++;
                break;
            }
            if (i  n-1 && arr[i]  arr[i + 1]) {
                while (i  n-1 && arr[i] = arr[i + 1]) {
                    i++;
                }
                i++;
                count++;
            } 
            if (i  n-1 && arr[i]  arr[i + 1]){
                while (i  n-1 && arr[i] = arr[i + 1]) {
                    i++;
                }
                i++;
                count++;
            }
            while (i  n-1 && arr[i] == arr[i + 1]) {
                i++;
            }
        }
        System.out.println(count);
    }
}